<?php

class Form_Courrier extends Zend_Form
{
	public function __construct($options = null)
	{
		parent::__construct($options);
		$this->setName('abonne');

		$id = new Zend_Form_Element_Hidden('id');

		$titre = new Zend_Form_Element_Text('titre');
		$titre->setLabel('titre')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');

		$chapo = new Zend_Form_Element_Text('chapo');
		$chapo->setLabel('chapo')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');

		$text = new Zend_Form_Element_Textarea('corps');
		$text->setAttribs(array('cols' => 35,'rows' => 6));
		$text->setLabel('corps')
		->setRequired(true)
		->addValidator('NotEmpty');
		 


		$piedpage = new Zend_Form_Element_Text('piedpage');
		$piedpage->setLabel('piedpage')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');

		$auteur = new Zend_Form_Element_Text('auteur');
		$auteur->setLabel('auteur')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');

		//Selectionner des newsletters

		$idNews = new Zend_Form_Element_Multiselect('newsletter');
		$idNews->setLabel('courrier_newsletter')
		->setRequired(true);
		$valueOptions = new Model_DbTable_Newsletters();
		
		if(!is_null($options)){
			if(array_key_exists('new_newsletter',$options)){
				$newsletters =$options['new_newsletter'];
			}
		}else {
			$newsletters = $valueOptions->getAllNewsletter();
		}
		$idNews->addMultiOptions($newsletters);


		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setAttrib('id', 'submitbutton');



		$this->addElements(array($id,$titre,$chapo,$text,$piedpage,$auteur,$idNews,$submit));
	}



	 
}